package com.hbpu.encap.collection;

import java.util.ArrayList;

public class Homework01 {
    public static void main(String[] args) {
        News news = new News("新冠确诊病例超千万，数百万印度教信徒赴恒河“圣浴”引民众担忧");
        News news1 = new News("男子突然想起2个月前钓的鱼还在网兜里，捞起一看赶紧放生");
        ArrayList<News> news2 = new ArrayList<>();
        news2.add(news);
        news2.add(news1);
        for (int i = news2.size() - 1; i >= 0; i--) {
            System.out.println(news2.get(i).toString());
        }
    }
}

class News {
    String title;
    String content;
    public News(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "News：" + title.substring(0, 16) + "...";
    }
}
